package com.keyinong.park.util;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.keyinong.park.R;

public class PhoneDialogHint {
	public static void dailog(final Context context, String name, final String phone) {
		final Dialog dialog = new Dialog(context);
		dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
		View view = LayoutInflater.from(context).inflate(
				R.layout.dialog_isphone, null);
		TextView tv_dailogPhone = (TextView) view
				.findViewById(R.id.tv_dailogPhone);
		TextView tv_dailogCancelDail = (TextView) view
				.findViewById(R.id.tv_dailogCancelDail);
		TextView tv_dailogDail = (TextView) view
				.findViewById(R.id.tv_dailogDail);
		dialog.setContentView(view);
		dialog.show();
		tv_dailogPhone.setText(name + "\n" + phone);
		tv_dailogCancelDail.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				dialog.dismiss();
			}
		});
		tv_dailogDail.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intentphone = new Intent(Intent.ACTION_CALL);
				Uri data = Uri.parse("tel:" + phone);
				intentphone.setData(data);
				context.startActivity(intentphone);
				dialog.dismiss();
			}
		});
	}

}
